package com.example.test.controller;

import com.example.test.pojo.User;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;

@RestController
@RequestMapping("/validate")
@Validated
public class ValidationController {
    @PostMapping("/user")
    public String test1(@Validated @RequestBody User user){
        return "add user successfully! " + user;
    }

    @PostMapping("/param")
    public String test2(@RequestParam("id") @Min(10) int id){
        return "add user successfully! " + id;
    }

    @GetMapping("/user/{id}")
    public String test3(@PathVariable("id") @Min(10) int id) {
        return "User id is " + id;
    }
}